//
//  BindPhoneSecrectModel.swift
//  DollBuy
//
//  Created by 郑东喜 on 2016/11/28.
//  Copyright © 2016年 郑东喜. All rights reserved.
//  绑定第三方授权账号密码

import UIKit

class BindPhoneSecrectModel: NSObject {

    static let shared = BindPhoneSecrectModel()
    
    //外部闭包变量
    var comfun:((_ _data:String)->Void)?
    
    func bindSecrect(passStr : String,comfun:((_ _data:String)->Void)?) -> Void {
        //本地取token
        guard let token = localSave.object(forKey: userToken) as? String else {
            return
        }
        
        let params = ["token" : token,
                      "pwd" : passStr]
        
        postWithPath(path: setacctURL, paras: params, success: { (response) in
            self.comfun = comfun
            
            guard let dic = response as? NSDictionary else {
                return
            }
            
            print(dic)
            
            //提取提示语
            guard let alertmsg = dic["resultmsg"] as? String else {
                return
            }
            
            //接收返回的值
            self.comfun!(alertmsg)
            
            if alertmsg == "成功" {
                MBManager.showBriefAlert(bindPassSuccess)
            }
            

            self.comfun!(alertmsg)
        }) { (error) in
            self.comfun!(error.localizedDescription)
            print(error.localizedDescription)
        }
        
    }
}
